<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>订单页面</title>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <!-- 引入组件库 -->
    <script src="../../static/js/Vue-2.6.12.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../static/js/axios.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/wangeditor@latest/dist/wangEditor.min.js"></script>

    <style>
        .el-row {
            margin-bottom: 20px;

        &
        :last-child {
            margin-bottom: 0;
        }

        }
        .el-col {
            border-radius: 4px;
        }

        .grid-content {
            border-radius: 4px;
            min-height: 36px;
        }

        .row-bg {
            padding: 10px 0;
            background-color: #f9fafc;
        }

        .avatar-uploader .el-upload {
            border: 1px dashed #d9d9d9;
            border-radius: 6px;
            cursor: pointer;
            position: relative;
            overflow: hidden;
        }

        .avatar-uploader .el-upload:hover {
            border-color: #409EFF;
        }

        .avatar-uploader-icon {
            font-size: 28px;
            color: #8c939d;
            width: 178px;
            height: 178px;
            line-height: 178px;
            text-align: center;
        }

        .avatar {
            width: 178px;
            height: 178px;
            display: block;
        }

        .el-drawer {
            overflow: scroll;
        }
    </style>
</head>
<body>
<div id="app">

    <el-row>
        <el-col :span="3">
            <div class="grid-content"></div>
        </el-col>
    </el-row>
    <el-row>
        <el-col :span="3">
            <div class="grid-content"></div>
        </el-col>
        <el-col :span="18">
            <el-form :inline="true" :model="searForm" class="demo-form-inline">
                <el-form-item>
                    <el-input clearable v-model="searForm.id" placeholder="id"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-input clearable v-model="searForm.username" placeholder="用户名"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="findList">查询</el-button>
                </el-form-item>
            </el-form>

            <el-table
                    :data="dataList"
                    border
                    style="width: 100%">
                <el-table-column
                        prop="id"
                        label="id"
                        width="180">
                </el-table-column>
                <el-table-column
                        prop="username"
                        label="用户名称"
                        width="180">
                </el-table-column>

                <el-table-column
                        label="操作">
                    <template slot-scope="scope">
                        <el-link type="primary" @click="getbyid(scope.row.id)">查看</el-link>
                    </template>
                </el-table-column>
            </el-table>
            <el-pagination
                    @size-change="findList"
                    @current-change="findList"
                    :current-page.sync="currentPage"
                    :page-sizes="[10, 20, 30, 40]"
                    :page-size.sync="pagesize"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="total">
            </el-pagination>
        </el-col>
        <el-col :span="3">
            <div class="grid-content bg-purple"></div>
        </el-col>
    </el-row>


    <el-drawer
            title="订单详情!"
            :before-close="handleClose"
            :visible.sync="dialog"
            direction="rtl"
            custom-class="demo-drawer"
            ref="drawer"
            size="60%">
        <div class="demo-drawer__content">

            <el-collapse>
                <div v-for="item in ordervo.orderItems">
                    <el-collapse-item :title="item.name" :name="item.name">
                        <div style="position: relative">
                            <a href="#">
                                <el-image
                                        style="width: 100px; height: 100px ;"
                                        :src="item.image"
                                        fit="fit"></el-image>
                                <span style="position: absolute;top: 0px;color: red">{{item.name}}</span>
                                <span style="position: absolute;top: 0px;right:0px;color: red">{{item.price}}</span>
                                <span style="position: absolute;bottom: 0px; right: 0px;font-weight: bold"><span
                                        style="font-weight: normal">共{{item.num}}件商品</span>实付：{{item.payMoney}}</span>
                            </a>
                        </div>
                    </el-collapse-item>
                </div>
            </el-collapse>

        </div>
    </el-drawer>

</div>
</body>

<script type="text/javascript">
    new Vue({
        el: "#app",
        data: {
            dataList: [],
            currentPage: 1,
            pagesize: 20,
            total: 100,
            searForm: {},
            dialog: false,
            ordervo: {}
        },
        created() {
            this.findList()
        },
        methods: {
            findList() {
                axios.post(`/order/findConditionPage.do?startpage=${this.currentPage}&pagesize=${this.pagesize}`, this.searForm).then((res) => {
                    this.dataList = res.data.records
                    this.total = res.data.total
                })
            },
            getbyid(id) {
                axios.get(`/order/findOrderVoItemByOrderId.do?id=${id}`).then((res) => {
                    this.ordervo = res.data
                    this.dialog = true
                }).catch((err) => {
                    this.$message.info(err)
                })
            },
            handleClose(done) {
                done()
            }
        }
    })
</script>
</html>